<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tlds/workflow.tld" prefix="wf"%>
<%@ taglib uri="http://org.gocom.bpm.platform/tags/processgraph" prefix="p"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>流程图</title>
	<%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp" %>
	<script type="text/javascript" src="<%=request.getContextPath()%>/workflow/wfcomponent/web/js/Graphic.js"></script>
</head>
	<%
		String processInstId = request.getParameter("processInstId");
		String zoom = request.getParameter("zoomvalue");
		if(zoom==""||zoom==null)
		{
			zoom = "1";	
		}
	 %>
<body style="text-align:center;">
	<!-- Description:流程未启动，则不显示
		 Author:chenhe            -->
	<% if(!"null".equals(processInstId) && !"".equals(processInstId)) {%>
		<p:processGraph processInstID="<%=processInstId%>" showNote="true" zoomQuotiety="<%=zoom %>">
			 <p:activityGraph activityType="start" />
			 <p:activityGraph activityType="manual" onclick=" openActivityDialog(event, this)"/>
			 <p:activityGraph activityType="finish" />
		</p:processGraph>
	<% } else {%>
		<div><h4>流程尚未启动</h4></div>
	<% } %>
	<script type="text/javascript">
	  	// 流程中的点  点击事件
		function openActivityDialog(e, actObj){
			if(actObj.getAttribute('processInstID') == null)
				return;
			// 兼容ff、ie	
			var event = e || window.event; 
			//tips显示内容
			var strMsg = "";
			//tips显示背景
			var state = "info";
			var activityInstId = actObj.getAttribute('activityInstId');
        	var json = nui.encode({activityInstId:activityInstId});
	        $.ajax({
	            url: "com.atozsoft.wf.wfgraph.queryWorkItemById.biz.ext",
	            type: 'POST',
	            data:json,
	            cache: false,
	            async: false,
	            contentType: 'text/json',
	            success: function(text) {
	                var datas = text.datas;
	                if(datas.length>0){
	                	strMsg = "<table style='font-size:12px;'>";
	                	workitemName = datas[0].workItemName;
	                	//strMsg = strMsg + "<tr><td>节点名称：" + workitemName +"</td></tr>";
	                	for(var i=0;i<datas.length;i++){
	                		var data = datas[i];
	                		var currentState = data.currentState;
			                if(currentState==12){
			                	strMsg = strMsg + "<tr><td>审批者：" + data.assistantName + "</td></tr><!-- <tr><td>审批状态：已审批</td></tr> --><tr><td>审批时间：" + data.endTime.substring(0,data.endTime.length-2) +"</td></tr>";
			                }else if(currentState==4 || currentState==10){
			                	strMsg = strMsg + "<tr><td>审批者：" + data.partiName + "</td></tr><!-- <tr><td>审批状态：待审批</td></tr> -->";
			                }else if(currentState==8){
			                	strMsg = strMsg + "<tr><td>审批者：" + data.partiName + "</td></tr><!-- <tr><td>审批状态：挂起</td></tr> -->";
	                	 	}else{
			                	strMsg = strMsg + "<tr><td>审批者：" + data.partiName + "</td></tr><!-- <tr><td>审批状态：终止</td></tr> -->";
			                }
	                	} 
	                	strMsg = strMsg + "</table>";
	                }else{
	                	strMsg = "无查询结果";
	                }
	          }
	        });
     
	        /* var x = event.clientX;
	        var y = event.clientY; */
	        /* add by chenhe*/
			var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
            var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
            var x = event.pageX || event.clientX + scrollX;
            var y = event.pageY || event.clientY + scrollY;
		
	        mini.showTips({
	            content: strMsg,
	            state: state,
	            x: x,
	            y: y,
	            timeout: 2000
	        });  
		}
		
		// 流程开始点 点击事件
		function showStart(){
			//tips显示内容
			var strMsg = "流程实例启动！";
			//tips显示背景
			var state = "info";
			/* var x = event.clientX;
	        var y = event.clientY; */
	        
			var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
            var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
            var x = event.pageX || event.clientX + scrollX;
            var y = event.pageY || event.clientY + scrollY;
	        
	        mini.showTips({
	            content: strMsg,
	            state: state,
	            x: x,
	            y: y
	        });
		}
		
		// 流程结束点 点击事件
		function showFinish(){
			//tips显示内容
			var strMsg = "流程实例结束！";
			//tips显示背景
			var state = "info";
			/* var x = event.clientX;
	        var y = event.clientY; */
	        
			var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
            var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
            var x = event.pageX || event.clientX + scrollX;
            var y = event.pageY || event.clientY + scrollY;
	        mini.showTips({
	            content: strMsg,
	            state: state,
	            x: x,
	            y: y
	        });
		}
		
		// 对象键值对输出
	    function po(obj){
			var temp = "";
			for(var i in obj){
				temp += i+":"+obj[i]+"\n";
			}
			document.write(temp);
			document.write("<br><br>");
		}
	</script>
    		
</body>
</html>
